package com.yuandian.ops.workbench.controller;


import com.yuandian.api.business_monitor.po.AlarmParams;
import com.yuandian.bpm.common.core.util.R;
import com.yuandian.ops.workbench.service.IBusinessAlarmService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;

/**
 * 告警业务查询 Controller
 *
 * @author LinShiHe
 * @date 2023/03/12
 */
@RestController
@RequestMapping("/ywgzt/business")
@Api(tags = "告警业务查询-Controller")
public class BusiAlarmYwgztController {


    @Autowired
    private IBusinessAlarmService businessAlarmService;

    /**
     * 查询告警业务信息
     * @param params 请求参数对象
     * @return 通用返回对象
     */
	@ApiOperation(value = "历史告警查询-告警业务查询列表", notes = "历史告警查询-告警业务查询列表")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "systemId", 				value = "系统id",  			paramType = "query", required = false,  dataType = "Integer"),
			@ApiImplicitParam(name = "businessCodes", 			value = "业务编码列表", 		paramType = "query", required = false,  dataType = "List<String>"),
			@ApiImplicitParam(name = "orderByColumn", 			value = "排序字段", 			paramType = "query", required = false,  dataType = "String"),
			@ApiImplicitParam(name = "isAsc", 					value = "升降序:ASC，DESC",  paramType = "query",  required = false, dataType = "String"),
			@ApiImplicitParam(name = "pageNum",				 	value = "页码",    			paramType = "query", required = true,   dataType = "Long"),
			@ApiImplicitParam(name = "pageSize", 				value = "每页大小", 			paramType = "query", required = true,   dataType = "Long"),
			@ApiImplicitParam(name = "startTime", 				value = "开始时间", 			paramType = "query", required = true,   dataType = "String"),
			@ApiImplicitParam(name = "endTime", 				value = "结束时间", 			paramType = "query", required = true,   dataType = "String")
	})
	@PostMapping("/getBusinessAlarm")
    public R<Object> getBusinessAlarm(@RequestBody AlarmParams params) {
        return businessAlarmService.getBusinessAlarm(params);
    }


    /**
     * 告警业务查询下载
     * @param params 请求参数对象
	 */
	@ApiOperation(value = "历史告警查询-告警业务查询列表", notes = "历史告警查询-告警业务查询列表")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "systemId", 				value = "系统id",  			paramType = "query", required = false,  dataType = "Integer"),
			@ApiImplicitParam(name = "businessCodes", 			value = "业务编码列表", 		paramType = "query", required = false,  dataType = "List<String>"),
			@ApiImplicitParam(name = "orderByColumn", 			value = "排序字段", 			paramType = "query", required = false,  dataType = "String"),
			@ApiImplicitParam(name = "isAsc", 					value = "升降序:ASC，DESC",  paramType = "query",  required = false, dataType = "String"),
			@ApiImplicitParam(name = "startTime", 				value = "开始时间", 			paramType = "query", required = true,   dataType = "String"),
			@ApiImplicitParam(name = "endTime", 				value = "结束时间", 			paramType = "query", required = true,   dataType = "String")
	})
    @PostMapping("/exportExcel")
    public void exportExcel(@RequestBody AlarmParams params, HttpServletResponse response) throws IOException {
        businessAlarmService.exportExcel(params, response);
    }



	/**
	 * npm告警详情
	 *
	 */
	@ApiOperation(value = "告警归并查询下载", notes = "告警归并查询下载")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "systemId",  			value = "系统id",  			paramType = "query", required = true,   dataType = "Integer"),
			@ApiImplicitParam(name = "alarmStates",  		value = "告警分类",  		paramType = "query", required = false,  dataType = "List<Integer>"),
			@ApiImplicitParam(name = "alarmTypeId",  		value = "告警类型",  		paramType = "query", required = false,   dataType = "Integer"),
			@ApiImplicitParam(name = "businessCodes", 		value = "业务编码",  		paramType = "query", required = false,  dataType = "List<String>"),
			@ApiImplicitParam(name = "segmentIds", 			value = "网端ID列表",  		paramType = "query", required = false,  dataType = "List<Integer>"),
			@ApiImplicitParam(name = "pageNum",   			value = "页码", 				paramType = "query", required = true,   dataType = "Long"),
			@ApiImplicitParam(name = "pageSize", 			value = "每页大小", 			paramType = "query", required = true,   dataType = "Long"),
			@ApiImplicitParam(name = "startTime", 			value = "开始时间", 			paramType = "query", required = true,   dataType = "String"),
			@ApiImplicitParam(name = "endTime",   			value = "结束时间", 			paramType = "query", required = true,   dataType = "String")
	})
	@PostMapping("/getAlarmMergeDownLoad")
	public void getAlarmMergeDownLoad(@RequestBody AlarmParams params, HttpServletResponse response) throws UnsupportedEncodingException {
		businessAlarmService.getAlarmMergeDownLoad(params, response);
	}

}
